<template>
  <div>
     <div class="bgf" style="display:flex;">
       <div id="content" style="width: 500px;height:400px;"></div>
       <div id="circle" style="width: 500px;height:400px;"></div>
     </div>
  </div>
</template>

<script>
// 导入Echart.js
import Echart from "echarts";
// 指定图表的配置项和数据
var option = {
    title: {
        text: 'ECharts 入门示例'
    },
    tooltip: {},
    legend: {
        data:['销量']
    },
    xAxis: {
        data: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"]
    },
    yAxis: {},
    series: [{
        name: '销量',
        type: 'bar',
        data: [5, 20, 36, 10, 10, 20]
    }]
};
var option2 = {
    tooltip: {
        trigger: 'item',
        formatter: '{a} <br/>{b}: {c} ({d}%)'
    },
    legend: {
        orient: 'vertical',
        left: 10,
        data: ['直接访问', '邮件营销', '联盟广告', '视频广告', '搜索引擎']
    },
    series: [
        {
            name: '访问来源',
            type: 'pie',
            radius: ['50%', '70%'],
            avoidLabelOverlap: false,
            label: {
                show: false,
                position: 'center'
            },
            emphasis: {
                label: {
                    show: true,
                    fontSize: '30',
                    fontWeight: 'bold'
                }
            },
            labelLine: {
                show: false
            },
            data: [
                {value: 335, name: '直接访问'},
                {value: 310, name: '邮件营销'},
                {value: 234, name: '联盟广告'},
                {value: 135, name: '视频广告'},
                {value: 1548, name: '搜索引擎'}
            ]
        }
    ]
};


export default {
    data(){
        return{}
    },
    methods:{},
    mounted(){
       // 初始化一个Echart对象
       var myChart = Echart.init(document.getElementById('content'));
       // 设置数据
        myChart.setOption(option);

       // 初始化一个Echart对象
       var myChart2 = Echart.init(document.getElementById('circle'));
       // 设置数据
        myChart2.setOption(option2); 
    }

}

// 第一次挂载完成之后 去初始化插件
// 数据请求成功之后也要记得初始化插件

</script>
<style scoped>
</style>